package Gui;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;

import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;

import Logic.LoginInfo;

import client.LibaryMain;
import javax.swing.ImageIcon;
/**
 * this class implements return book gui 
 * @author Ron Shenkerman
 * @author Gabi Revah
 * @author Aviad Almog
 * @author Ivan Onyshchenko
 */
public class ReturnBookgui extends JPanel{
	private JTextField bookidtext;
	
	/**
	 * constractor of this class 
	 * create return book window
	 */
	public ReturnBookgui() {
		setBackground(new Color(153, 204, 255));
		init();
	}
		/**
		 *  initilizing  return book window 
		 */
		public void init(){
		
		
		
		
		JLabel lblNewLabel = new JLabel("Return a Book");
		lblNewLabel.setBounds(126, 57, 237, 19);
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD | Font.ITALIC, 26));
		
		JLabel lblBookId = new JLabel("Book ID");
		lblBookId.setBounds(252, 348, 65, 20);
		lblBookId.setFont(new Font("Tahoma", Font.BOLD, 16));
		
		bookidtext = new JTextField();
		bookidtext.setBounds(339, 346, 174, 28);
		bookidtext.setColumns(10);
		
		JButton btnReturn = new JButton("Return Book");
		btnReturn.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnReturn.setBounds(525, 344, 141, 28);
		
		
		btnReturn.addActionListener(new java.awt.event.ActionListener() {     
            public void actionPerformed(java.awt.event.ActionEvent ev) {
            	btnReturnaction(ev);
            					
			}

			public void btnReturnaction(ActionEvent ev) {
				 String bookid=bookidtext.getText();
				 ArrayList<String> Arr=new ArrayList<String>();
		         Arr.add("ReturnBook");
		         Arr.add(bookid);
		         LibaryMain.chat.handleMessageFromGui(Arr);
			
			}
		});
		
		
		JButton btnBack = new JButton("Back");
		btnBack.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnBack.setBounds(209, 603, 90, 25);
		
		btnBack.addActionListener(new java.awt.event.ActionListener() {     //  back to  subscriber 
            public void actionPerformed(java.awt.event.ActionEvent evt) {
            	btnBackActionPerformed(evt);
            
            }

					private void btnBackActionPerformed(ActionEvent evt) {
						
						MainScreen.cardLayot.show(MainScreen.card, DirectorWindow.roll);
						
					}
				
        });
		
		JButton btnLogout = new JButton("Logout");
		btnLogout.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnLogout.setBounds(652, 600, 85, 28);
		
		btnLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				ArrayList<String> Arr=new ArrayList<String>();
				Arr.add("Logout");
				Arr.add("Worker");
				Arr.add(LoginInfo.UserName);
				LibaryMain.chat.handleMessageFromGui(Arr);
				MainScreen.cardLayot.show(MainScreen.card, "Login");
				
			}
		});
		setLayout(null);
		
		JLabel label = new JLabel("");
		label.setBounds(574, 154, 256, 256);
		label.setIcon(new ImageIcon(ReturnBookgui.class.getResource("/Gui/images/go-back-icon.png")));
		add(label);
		add(lblNewLabel);
		add(lblBookId);
		add(bookidtext);
		add(btnReturn);
		add(btnBack);
		add(btnLogout);
	}



}
